home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / memory / src / addmemlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  2.0 KB  |  86 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: addmemlist.c 1.1 1995/11/14 22:31:07 digulla Exp digulla $
  4.     $Log: addmemlist.c $
  5.  * Revision 1.1  1995/11/14  22:31:07  digulla
  6.  * Initial revision
  7.  *
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include "exec_intern.h"
  12. #include "memory.h"
  13. #include <exec/memory.h>
  14.  
  15. /*****************************************************************************
  16.  
  17.     NAME */
  18.     #include <clib/exec_protos.h>
  19.  
  20.     __AROS_LH5(void, AddMemList,
  21.  
  22. /*  SYNOPSIS */
  23.     __AROS_LA(unsigned long, size, D0),
  24.     __AROS_LA(unsigned long, attributes, D1),
  25.     __AROS_LA(long         , pri, D2),
  26.     __AROS_LA(APTR         , base, A0),
  27.     __AROS_LA(UBYTE       *, name, A1),
  28.  
  29. /*  LOCATION */
  30.     struct ExecBase *, SysBase, 103, Exec)
  31.  
  32. /*  FUNCTION
  33.     Add a new block of memory to the system memory lists.
  34.  
  35.     INPUTS
  36.     size       - Size of the block
  37.     attributes - The attributes the memory will have
  38.     pri       - Priority in the list of MemHeaders
  39.     base       - Base address
  40.     name       - A name associated with the memory
  41.  
  42.     RESULT
  43.  
  44.     NOTES
  45.     No argument checking done.
  46.  
  47.     EXAMPLE
  48.  
  49.     BUGS
  50.  
  51.     SEE ALSO
  52.  
  53.     INTERNALS
  54.  
  55.     HISTORY
  56.     08-10-95    created by m. fleischer
  57.     16-10-95    increased portability
  58.     26-10-95    digulla adjusted to new calling scheme
  59.  
  60. ******************************************************************************/
  61. {
  62.     __AROS_FUNC_INIT
  63.     struct MemHeader *mh;
  64.  
  65.     /* Do I have to look here if it matches some other MemHeader? */
  66.     mh=(struct MemHeader *)base;
  67.     mh->mh_Node.ln_Type=NT_MEMORY;
  68.     mh->mh_Node.ln_Pri=pri;
  69.     mh->mh_Node.ln_Name=name;
  70.     mh->mh_Attributes=attributes;
  71.     mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
  72.     mh->mh_First->mc_Next=NULL;
  73.     mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
  74.     mh->mh_Lower=mh->mh_First;
  75.     mh->mh_Upper=(APTR)((UBYTE *)base+size);
  76.     mh->mh_Free=mh->mh_First->mc_Bytes;
  77.  
  78.     /* Protect the memory list. */
  79.     Forbid();
  80.     /* Add MemHeader */
  81.     Enqueue(&SysBase->MemList,&mh->mh_Node);
  82.     Permit();
  83.     __AROS_FUNC_EXIT
  84. } /* AddMemList */
  85.  
  86.